package com.zking.ssm.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zking.ssm.sys.mapper.HotelBrandTypeMapper;
import com.zking.ssm.sys.model.HotelBrandType;
import com.zking.ssm.sys.service.IHotelBrandTypeService;
import com.zking.ssm.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelBrandTypeServiceImpl implements IHotelBrandTypeService {
    @Autowired
    private HotelBrandTypeMapper hotelBrandTypeMapper;

    public HotelBrandTypeServiceImpl() {

    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return hotelBrandTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(HotelBrandType record) {
        return hotelBrandTypeMapper.insert(record);
    }

    @Override
    public int insertSelective(HotelBrandType record) {
        return hotelBrandTypeMapper.insertSelective(record);
    }

    @Override
    public HotelBrandType selectByPrimaryKey(Long id) {
        return hotelBrandTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(HotelBrandType record) {
        return hotelBrandTypeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(HotelBrandType record) {
        return hotelBrandTypeMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<HotelBrandType> list(HotelBrandType record, PageBean pageBean) {
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageHelper.startPage(pageBean.getPage(), pageBean.getRows());
        }
        List<HotelBrandType> list = hotelBrandTypeMapper.list(record);
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageInfo pageInfo = new PageInfo(list);
            pageBean.setTotal(pageInfo.getTotal() + "");
        }
        return list;
    }
}
